{
  Объекты для отображения на схемах

 TVisualElement

   версия 0.1 декабрь 2010 prodg@ya.ru D.Kondakov
}
unit VislObjects;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, Graphics;

type

  TVisualLayer = class

  end;


                  { - p r l t g b m }
  TVslElmntType = (vetUnknown, vetPoint, vetRegion, vetLine, vetText, vetGroup, vetPicture, vetPoly);

  { TVisualElement }

  TVisualElementClass = class of TVisualElement;
  TVisualElement = class(TCollectionItem)
  private
    FElementType: TVslElmntType;
  public
    property ElementType: TVslElmntType read FElementType;
    constructor Create(ACollection: TCollection; AType: TVslElmntType);
    destructor Destroy; override;
    function GetData: string; virtual;
    procedure SetData(src: string); virtual;
    function IsPointIn(Point: TPoint): Boolean; virtual;
  protected
    procedure Draw(Canvas: TCanvas); virtual;
//    function Resize: boolean;
//    function Move: boolean;
  end;

                 { o x + v # ^ * }
  TVslPntStyle = (vpsCircle, vpsCros, vpsPlus, vpsRombe, vpsSquare, vpsTriangle, vpsStar);

  { TVEPoint }

  TVEPoint = class(TVisualElement)
  private
    FSize: integer;
    procedure SetSize(const AValue: integer);
  protected
    procedure Draw(Canvas: TCanvas); override;
  public
    property Size: integer read FSize write SetSize;
    constructor Create(ACollection: TCollection);
    function GetData: string; override;
    procedure SetData(src: string); override;
    function IsPointIn(Point: TPoint): Boolean; override;
  end;

  { TVELine }

  TVELine = class(TVisualElement)
  protected
    procedure Draw(Canvas: TCanvas); override;
  public
    constructor Create(ACollection: TCollection);
    function GetData: string; override;
    procedure SetData(src: string); override;
    function IsPointIn(Point: TPoint): Boolean; override;
  end;

  { TVEGroup }

  TVEGroup = class(TVisualElement)
  private
    vegItems: TList;
    function GetItem(i: integer): TVisualElement;
  protected
    property Elements[Index: integer]: TVisualElement read GetItem;
    procedure Draw(Canvas: TCanvas); override;
  public
    constructor Create(ACollection: TCollection);
    function GetData: string; override;
    procedure SetData(src: string); override;
    function IsPointIn(Point: TPoint): Boolean; override;
  end;

  { TVERegion }

  TVERegion = class(TVisualElement)
  private
    FHeight: Word;
    FWidth: Word;
    procedure SetHeight(const AValue: Word);
    procedure SetWidth(const AValue: Word);
  published
    property Width: Word read FWidth write SetWidth;
    property Height: Word read FHeight write SetHeight;
  protected
    procedure Draw(Canvas: TCanvas); override;
  public
    constructor Create(ACollection: TCollection);
    function GetData: string; override;
    procedure SetData(src: string); override;
    function IsPointIn(Point: TPoint): Boolean; override;
  end;

  { TVEPicture }

  TVEPicture = class(TVERegion)
  private
    FImg: TSharedImage;
  protected
    procedure Draw(Canvas: TCanvas); override;
  public
    constructor Create(ACollection: TCollection);
    function GetData: string; override;
    procedure SetData(src: string); override;
    function IsPointIn(Point: TPoint): Boolean; override;
  end;

  { TVEText }

  TVEText = class(TVisualElement)
  private
    FText: String;
    procedure SetText(const AValue: String);
  published
    property Text: String read FText write SetText;
  protected
    procedure Draw(Canvas: TCanvas); override;
  public
    constructor Create(ACollection: TCollection);
    function GetData: string; override;
    procedure SetData(src: string); override;
    function IsPointIn(Point: TPoint): Boolean; override;
  end;

  { TVEMultiLine }

  TVEMultiLine = class(TVEGroup)
  protected
    procedure Draw(Canvas: TCanvas); override;
  public
    constructor Create(ACollection: TCollection);
    function GetData: string; override;
    procedure SetData(src: string); override;
    function IsPointIn(Point: TPoint): Boolean; override;
  end;

implementation

constructor TVisualElement.Create(ACollection: TCollection; AType: TVslElmntType);
begin
  inherited Create(ACollection);
  FElementType := AType;
end;

destructor TVisualElement.Destroy;
begin

  inherited;
end;

function TVisualElement.GetData: string;
begin

end;

procedure TVisualElement.SetData(src: string);
begin

end;

function TVisualElement.IsPointIn(Point: TPoint): Boolean;
begin

end;

procedure TVisualElement.Draw(Canvas: TCanvas);
begin

end;

{ TVEPoint }

procedure TVEPoint.SetSize(const AValue: integer);
begin
  if FSize = AValue then exit;
  FSize := AValue;
end;

procedure TVEPoint.Draw(Canvas: TCanvas);
begin
  inherited Draw(Canvas);
end;

constructor TVEPoint.Create(ACollection: TCollection);
begin
  inherited Create(ACollection, vetPoint);
end;

function TVEPoint.GetData: string;
begin
  Result := inherited GetData;
end;

procedure TVEPoint.SetData(src: string);
begin
  inherited SetData(src);
end;

function TVEPoint.IsPointIn(Point: TPoint): Boolean;
begin
  Result := inherited IsPointIn(Point);
end;

{ TVELine }

procedure TVELine.Draw(Canvas: TCanvas);
begin
  inherited Draw(Canvas);
end;

constructor TVELine.Create(ACollection: TCollection);
begin

end;

function TVELine.GetData: string;
begin
  Result := inherited GetData;
end;

procedure TVELine.SetData(src: string);
begin
  inherited SetData(src);
end;

function TVELine.IsPointIn(Point: TPoint): Boolean;
begin
  Result := inherited IsPointIn(Point);
end;

function TVEGroup.GetItem(i: integer): TVisualElement;
begin
  Result := TVisualElement(vegItems[i]);
end;

procedure TVEGroup.Draw(Canvas: TCanvas);
begin

end;

constructor TVEGroup.Create(ACollection: TCollection);
begin

end;

function TVEGroup.GetData: string;
begin
  Result := inherited GetData;
end;

procedure TVEGroup.SetData(src: string);
begin
  inherited SetData(src);
end;

function TVEGroup.IsPointIn(Point: TPoint): Boolean;
begin
  Result := inherited IsPointIn(Point);
end;

procedure TVERegion.SetHeight(const AValue: Word);
begin
  if FHeight = AValue then exit;
  FHeight := AValue;
end;

procedure TVERegion.SetWidth(const AValue: Word);
begin
  if FWidth = AValue then exit;
  FWidth := AValue;
end;

procedure TVERegion.Draw(Canvas: TCanvas);
begin

end;

constructor TVERegion.Create(ACollection: TCollection);
begin

end;

function TVERegion.GetData: string;
begin
  Result := inherited GetData;
end;

procedure TVERegion.SetData(src: string);
begin
  inherited SetData(src);
end;

function TVERegion.IsPointIn(Point: TPoint): Boolean;
begin
  Result := inherited IsPointIn(Point);
end;

procedure TVEPicture.Draw(Canvas: TCanvas);
begin

end;

constructor TVEPicture.Create(ACollection: TCollection);
begin

end;

function TVEPicture.GetData: string;
begin
  Result := inherited GetData;
end;

procedure TVEPicture.SetData(src: string);
begin
  inherited SetData(src);
end;

function TVEPicture.IsPointIn(Point: TPoint): Boolean;
begin
  Result := inherited IsPointIn(Point);
end;

procedure TVEText.SetText(const AValue: String);
begin
  if FText = AValue then exit;
  FText := AValue;
end;

procedure TVEText.Draw(Canvas: TCanvas);
begin

end;

constructor TVEText.Create(ACollection: TCollection);
begin

end;

function TVEText.GetData: string;
begin
  Result := inherited GetData;
end;

procedure TVEText.SetData(src: string);
begin
  inherited SetData(src);
end;

function TVEText.IsPointIn(Point: TPoint): Boolean;
begin
  Result := inherited IsPointIn(Point);
end;

{ TVEMultiLine }

procedure TVEMultiLine.Draw(Canvas: TCanvas);
begin
  inherited Draw(Canvas);
end;

constructor TVEMultiLine.Create(ACollection: TCollection);
begin

end;

function TVEMultiLine.GetData: string;
begin
  Result := inherited GetData;
end;

procedure TVEMultiLine.SetData(src: string);
begin
  inherited SetData(src);
end;

function TVEMultiLine.IsPointIn(Point: TPoint): Boolean;
begin
  Result := inherited IsPointIn(Point);
end;

end.

